// 这个第三方库用于将url参数转变为对象形式 id=111&name=123 => {id:111,name:123}
import qs from 'qs';
export default {
    "GET /users": { name: 'wanShell', pwd: '123' },
    "POST /users/login": (req: any, res: any) => {
        console.log(req.body);
        const { body: { userId, userPassword } } = req;
        if (userId === 'wanShell' && userPassword === '123') {
            res.send({
                msg: 'ok',
                code: '1'
            })
        }
        else {
            res.send({
                msg: 'fail',
                code: '0'
            })
        }
    },
    'get /right1': (req: any, res: any) => {
        const paramsObj = qs.parse(req._parsedOriginalUrl.query);
        console.log(paramsObj);
        switch (paramsObj.id) {
            case 'SuperAdmin':
                res.send({
                    msg: 'ok',
                    code: '1',
                    data: [
                        {
                            id: 1,
                            title: '首页',
                            key: '/home',
                            pagePermisson: 1,
                            grade: 1
                        },
                        {
                            id: 2,
                            title: '用户管理',
                            key: '/user-manage',
                            pagePermisson: 1,
                            grade: 1
                        },
                        {
                            id: 3,
                            title: '权限管理',
                            key: '/right-manage',
                            pagePermisson: 1,
                            grade: 1
                        },
                        {
                            id: 4,
                            title: '新闻管理',
                            key: '/new-manage',
                            pagePermisson: 1,
                            grade: 1
                        },
                        {
                            id: 5,
                            title: '审核管理',
                            key: '/andit-manage',
                            pagePermisson: 1,
                            grade: 1
                        },
                        {
                            id: 6,
                            title: '发布管理',
                            key: '/andit-manage',
                            pagePermisson: 1,
                            grade: 1
                        }
                    ]
                })
                break;
            case 'Admin':
                res.send({
                    msg: 'ok',
                    code: '1',
                    data: []
                })
                break;
            case 'Author':
                res.send({
                    msg: 'ok',
                    code: '1',
                    data: []
                })
                break;
            default:
                res.send({
                    msg: 'ok',
                    code: '1',
                    data: []
                })
                break;
        }

    }
}